<template>
  <div>
      用户名<input type="text" v-model="username">
      <input type="button" value="登录" @click="btn">
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
          username:''  
        }
    },methods:{
        btn(){
            axios.post('/api/login',{'username':this.username}).then(resp=>{
                console.log(resp.data)
                alert(resp.data.msg)
                if(resp.data.status==200){
                    sessionStorage.setItem('username',this.username)
                    this.$router.push('/journalism')
                } 
            }).catch(error=>{
                console.log(error)
            })
        }
    }
}
</script>

<style>

</style>